﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;

public partial class HomePage_BordList : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    public string WriteBord()
    {
        int i = 0;
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        //HZ.MBSM.DBUtility.Db db = new HZ.MBSM.DBUtility.Db();
        Db db = new Db();
        DbPage dbPage = new DbPage(db);
        dbPage.Table = "board";                                               //要查询的表明
        dbPage.Key = "id";                                               //表的主键    
        dbPage.Where = "";                                           //查询条件    
        dbPage.SelectField = "id,title,createdate";//要显示的字段
        dbPage.PageIndex = SysFun.ToInt(Request["CurrentlyPageIndex"]);          //要显示第几页   
        dbPage.PageSize = 24;                                                    //没有显示记录条数   
        dbPage.OrderBy = " id";                  //排序字段
        dbPage.OrderByIsDesc = true;
        System.Data.IDataReader dr = dbPage.ExecuteReader();

        sb.Append("<ul>");
        while (dr.Read())
        {
            i++;
            sb.Append("<li>");
            sb.Append("<div style='float:left'><img src='../images/gif-0057.gif' >&nbsp;<a href='Boardinfo.aspx?id=" + MsgBox.JiaMiobj_Encrypt(dr["id"].ToString()) + "' target=_blank>" + dr["Title"].ToString() + "</a>");
            if (System.DateTime.Now <= Convert.ToDateTime(dr["createdate"].ToString()).AddDays(2))
                sb.Append("&nbsp;<img src='../images/new.gif' width='28' height=11></div>");
            else
                sb.Append("</div>");
            sb.Append("<div class=\"TT\">[" + Convert.ToDateTime(dr["createdate"].ToString()).ToString("yy-MM-dd") + "]</div>");
            sb.Append("</li>");
        }

        sb.Append("</ul>");

        //sb.Append("<table  width='96%' border=0 align=center cellpadding=6 cellspacing=1>");
        //while (dr.Read())
        //{
        //    i++;
        //    sb.Append("<tr><td class='dotbottomline'>");
        //    sb.Append("<img src='../images/ico7.gif' width='8' height='5' hspace='4' vspace='1'>");
        //    //sb.Append("<a href='../HomePage/Boardinfo.aspx?Id=" + dr["id"].ToString() + "' target=_blank>" + dr["Title"].ToString() + "</a>");
        //    sb.Append("<a href='Boardinfo.aspx?id=" + MsgBox.JiaMiobj_Encrypt(dr["id"].ToString()) + "' target=_blank>" + dr["Title"].ToString() + "</a>");
        //    sb.Append("</td></tr>");
        //}
        //for (int j = i; j < 24; j++)
        //    sb.Append("<tr><td class='dotbottomline'>&nbsp;</td></tr>");

        //sb.Append("</table>");

        dr.Close();
        dr.Dispose();

        db.Close();
        this.DbPageFlip1.DbPage = dbPage;//将数据传给控键


        dbPage.Db.Close();

        return sb.ToString();
    }
}
